package _.mail;

import java.io.File;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import org.budo.mail.Mail;
import org.budo.mail.javax.internet.util.MimeUtil;

import _.mail.javax.ReceiveMailImpl;
import lombok.Getter;
import lombok.Setter;

/**
 * @author li
 * @version 1 (2014年6月27日 下午4:03:30)
 * @since Java7
 */
@Getter
@Setter
public class MailImpl implements Mail,Serializable {
    private static final long serialVersionUID = 8733452456986616769L;

    private String from;

    private String to;

    private String cc;

    private String bcc;

    private String subject;

    private String content;

    private String replyTo;

    private String sender;

    private List<File> attachmentList = new ArrayList<File>();

    public MailImpl() {}

    public MailImpl(String to, String subject, String content) {
        this(null, to, subject, content);
    }

    public MailImpl(String from, String to, String subject, String content) {
        this.from = from;
        this.to = to;
        this.subject = subject;
        this.content = content;
    }

    /**
     * toString
     */
    public String toString() {
        Class<?> type = this.getClass();

        if (type.equals(MailImpl.class) || type.equals(ReceiveMailImpl.class)) {
            return super.toString() // 
                    + ", from=" + MimeUtil.decodeText(getFrom()) // 
                    + ", to=" + MimeUtil.decodeText(getTo()) // 
                    + ", replyTo=" + this.getReplyTo() //
                    + ", sender=" + MimeUtil.decodeText(getSender()) //
                    + ", subject=" + this.getSubject();
        }

        return super.toString();
    }
}